package com.ruizhong.integratedmediawithoutc.util;

/**
 * 命令枚举类
 */
public enum CMD {
    Config("配置"),
    QueryConfig("查询配置"),
    Start("启动服务"),
    Stop("停止服务"),
    Login("登录", "{{user_name},[password]}"),
    Logout("退出登录"),
    AddUser("添加用户", "{{user_name},[password],[power],[start_time],[times]"),
    QueryUsers("查询所有用户", "{{user_name},[power],[start_time],[times]}"),
    QueryMaterial("查询所有的视频素材", "{{file_id},{file_name}}"),
    QueryR("查询所有资源", "{{file_id},{file_name}}"),
    QueryPL("查询所有的节目单", "{{pl_id}}", "{}"),
    QueryPlan("查询所有的计划任务", "{{id}}", "{}"),
    OnDemand("点播", "{{surfix},{file_id}}", "{{url}}"),
    StopOnDemand("关闭点播", "{{surfix}}"),
    PlayP("播放节目单", "{{pl_id}}"),
    StopP("关闭节目单播放", "{{pl_id}}"),
    AddR("添加资源", "{{dst_code},{file_path}}"),
    AddPL("添加节目单", "{{pl_id},[surfix]}"),
    AddPLP("添加节目单", "{{pl_id},[pindex],[filepath],[duration]}"),
    AddPlan("添加计划任务", "{{freq},{days},{time},[cmd],[pl_id],[enabled]}"),
    De1R("删除资源", "{{file_id}}"),
    De1PL("删除节目单", "{{pl_id}}"),
    De1PLP("删除节目单", "{{pl_id},[pindex]}"),
    De1Plan("删除计划任务", "{{id}}"),
    None("无操作");

    private final String description;
    private String requestFormat;
    private String responseFormat;

    // 构造方法（无参数格式）
    CMD(String description) {
        this(description, null, null);
    }

    // 构造方法（带请求格式）
    CMD(String description, String requestFormat) {
        this(description, requestFormat, null);
    }

    // 完整构造方法
    CMD(String description, String requestFormat, String responseFormat) {
        this.description = description;
        this.requestFormat = requestFormat;
        this.responseFormat = responseFormat;
    }

    // Getter方法
    public String getDescription() {
        return description;
    }

    public String getRequestFormat() {
        return requestFormat;
    }

    public String getResponseFormat() {
        return responseFormat;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(name()).append(" (").append(description).append(")");
        if (requestFormat != null) {
            sb.append("\n  Request: ").append(requestFormat);
        }
        if (responseFormat != null) {
            sb.append("\n  Response: ").append(responseFormat);
        }
        return sb.toString();
    }
}